package com.zijing2333.servicerunner;

import android.os.Parcel;
import android.os.Parcelable;


public class TaskInfo implements Parcelable {
    private String taskId;
    private boolean isFrontendRequired;
    private String taskParams;

    @Override
    public String toString() {
        return "TaskInfo{" +
                "taskId='" + taskId + '\'' +
                ", isFrontendRequired=" + isFrontendRequired +
                ", taskParams='" + taskParams + '\'' +
                '}';
    }

    public TaskInfo(String taskId, boolean isFrontendRequired, String taskParams) {
        this.taskId = taskId;
        this.isFrontendRequired = isFrontendRequired;
        this.taskParams = taskParams;
    }

    protected TaskInfo(Parcel in) {
        taskId = in.readString();
        isFrontendRequired = in.readByte() != 0;
        taskParams = in.readString();
    }

    public static final Creator<TaskInfo> CREATOR = new Creator<TaskInfo>() {
        @Override
        public TaskInfo createFromParcel(Parcel in) {
            return new TaskInfo(in);
        }

        @Override
        public TaskInfo[] newArray(int size) {
            return new TaskInfo[size];
        }
    };

    public String getTaskId() {
        return taskId;
    }

    public boolean isFrontendRequired() {
        return isFrontendRequired;
    }

    public String getTaskParams() {
        return taskParams;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(taskId);
        dest.writeByte((byte) (isFrontendRequired ? 1 : 0));
        dest.writeString(taskParams);
    }
}
